<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<h:html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

<ui:composition template="masterPage.xhtml">

	<ui:define name="titulo">
		<h:outputLabel value="Login" />
		<input id="pagina" type="hidden" value="login"/>
	</ui:define>

	<ui:define name="centro">
		
		<p:growl id="growl" showDetail="true" life="3000" />
	
		<h:form>
			<p:panelGrid columns="2">
				<f:facet name="header">
					Autenticacao
				</f:facet>
				
				<h:outputText value="E-mail " />
				<h:inputText value="#{usuarioMBean.usuario.email}"/>
				<h:outputText value="Senha: " />
				<h:inputSecret value="#{usuarioMBean.usuario.senha}" />
				<f:facet name="footer" align="center">
					<h:panelGroup style="display:block; text-align:center">
						<p:commandButton id="Autenticar" value="Autenticar" icon="ui-icon-check" style="margin:0" 
							action="#{usuarioMBean.autentica}" update=":growl"/>
					</h:panelGroup>
				</f:facet>
			</p:panelGrid>
		</h:form>
		
		<br/>
		<p:commandButton id="idModalDialogButton" value="Cadastre-se aqui" onclick="dlgCadastro.show();"/>
		
		<p:dialog id="idDlgCadastro" header="Cadastro de usuário" widgetVar="dlgCadastro" modal="true">
			<h:form>
			    <p:panelGrid columns="2">
					<f:facet name="header">
						Novo usuário
					</f:facet>
					<h:outputText value="E-mail " />
							<h:inputText value="#{usuarioCadastroMBean.usuario.email}"/>
							<h:outputText value="Senha: " />
							<h:inputSecret value="#{usuarioCadastroMBean.usuario.senha}" />
							<h:outputText value="Nome: " />
							<h:inputText value="#{usuarioCadastroMBean.usuario.nome}"/>
							<h:outputText value="Endereço: " />
							<h:inputText value="#{usuarioCadastroMBean.usuario.endereco}"/>
							<h:outputText value="Telefone " />
							<h:inputText value="#{usuarioCadastroMBean.usuario.telefone}"/>
					<f:facet name="footer">
						<p:commandButton id="cadastrarButton" value="Cadastrar" update=":growl"   
							actionListener="#{usuarioCadastroMBean.cadastra}"   
	                    	oncomplete="handleLoginRequest(xhr, status, args)"/>
					</f:facet>
				</p:panelGrid>
			</h:form>
		</p:dialog>
			
	</ui:define>
	
</ui:composition>

</h:html>